<template>
  <a-modal
    title="申请退回"
    width="750px"
    centered
    :visible="returnVisible"
    :maskClosable="false"
    @cancel="close"
    :footer="null"
  >
    <a-form-model
      class="form approval-content"
      :model="form"
      v-bind="formLayout"
    >
      <a-form-model-item>
        <div slot="label" style="display: inline-block">
          <p>建议</p>
          <p>承办单位</p>
        </div>
        <div class="select-content">
          <a-select
            mode="tags"
            v-model="form.unitName"
            style="width: calc(100% - 80px)"
            @change="handleChange"
            :allowClear="false"
          >
            <a-select-option v-for="i in 25" :key="(i + 9).toString(36) + i">
              {{ (i + 9).toString(36) + i }}
            </a-select-option>
          </a-select>
          <a-button
            style="width: 54px;height:40px;"
            type="primary"
            @click="selectClick"
            >选择</a-button
          >
        </div>
      </a-form-model-item>
      <a-form-model-item label="短信提醒">
        <a-switch
          v-model="form.messageAlert"
          checked-children="开"
          un-checked-children="关"
          default-checked
        />
      </a-form-model-item>
      <a-form-model-item label="退回理由" required>
        <a-textarea
          v-model="form.reasons"
          placeholder="请输入退回理由"
          :rows="8"
          style="height: 200px"
        />
      </a-form-model-item>
      <a-form-model-item label="附件" required>
        <a-upload
          action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
          :multiple="true"
          :file-list="form.fileList"
        >
          <a-button> <a-icon type="upload" />选择文件</a-button>
        </a-upload>
      </a-form-model-item>
      <div class="form-footer">
        <a-button type="primary" @click="submit">确定</a-button>
        <a-button style="margin-left: 10px" @click="close"> 取消 </a-button>
      </div>
    </a-form-model>
    <!-- 建议承办单位弹框 -->
    <choiceModal
      :visible.sync="choiceModalVisible"
      @handleOk="handleOk"
    ></choiceModal>
  </a-modal>
</template>

<script>
import choiceModal from 'components/base/selectModal.vue'
export default {
  props: {
    returnVisible: {
      type: Boolean,
      default: false
    },
    //关闭弹框
    closeFunc: {
      type: Function,
      default: () => {}
    }
  },
  components: {
    choiceModal
  },
  data() {
    return {
      choiceModalVisible: false, //选择承办单位弹框
      formLayout: {
        labelCol: { span: 6 },
        wrapperCol: { span: 18 }
      },
      form: {
        unitName: [],
        messageAlert: false,
        reasons: '',
        fileList: []
      }
    }
  },
  methods: {
    handleOk(val) {
      console.log(val)
      this.$refs.select1.blur()
    },
    selectClick() {
      this.choiceModalVisible = true
    },
    //关闭弹框
    close() {
      this.$emit('closeFunc')
    },
    submit() {
      this.$emit('closeFunc')
    },
    handleChange(value) {
      this.form.unitName = value
    }
  }
}
</script>
<style lang="less" scoped>
.approval-content {
  max-height: 580px;
  overflow-y: auto;
}
.select-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
/deep/ .ant-select {
  color: #333;
  box-sizing: border-box;
  height: 40px;
  line-height: 40px;
}
/deep/ .ant-select-selection {
  border-radius: 2px;
  height: 40px;
  overflow: hidden;
}
/deep/ .ant-select-selection__rendered {
  line-height: 38px;
}
/deep/ .ant-select-selection--multiple > ul > li, .ant-select-selection--multiple .ant-select-selection__rendered > ul > li {
    height: 24px;
    margin-top: 7px;
    line-height: 22px;
}
</style>

